package com.example.chatper06;

import java.util.*;
public class DispDate {
    public String getTime(String str) {
        StringTokenizer cat = new StringTokenizer(str, " ");
        String temp = null;
        int num = 0;
        while (cat.hasMoreTokens() && num++ < 4) {
            temp = cat.nextToken();		}
        return temp;
    }
    public static void main(String[] args) {
        DispDate ob = new DispDate();
        Date dt = new Date();
        String str = dt.toString();
        System.out.println();
        System.out.println("Date对象对应的日期为：" + str);
        System.out.println();
        String thisTime = ob.getTime(str);
        System.out.println("当前时间为：" + thisTime);
    }
}
